<!--<template>
  <div>
    <div class="hot">
      <p class="title">最受好评电影</p>
      <ul>
        <li v-for="item in hotlist1" :key="item.id">
          <img :src="item.img" />
          <span class="nm">{{ item.nm }}</span>
          <div class="pinfen">
            <span v-if="item.sc > '0'">观众评分{{ item.mk }}</span>
            <span v-else>{{ item.wish }}想看</span>
          </div>
        </li>
      </ul>
    </div>
    <div class="list">
      <ul>
        <li v-for="item in hotlist" :key="item.id">
          <div class="item-img">
            <img :src="item.img" :alt="item.nm" />
          </div>
          <div class="item-text">
            <div class="item-tt">
              <h3>{{ item.nm }}</h3>
              <div v-if="item.scoreLabel == '暂无评分'">
                {{ item.scoreLabel }}
              </div>
              <div v-if="item.scoreLabel == '猫眼购票评分'">
                观众评:{{ item.mk }}
              </div>
              <div>主演：{{ item.star }}</div>
              <div>{{ item.showInfo }}</div>
            </div>
            <div class="item-btn">
              <div>购票</div>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Hot",
  data() {
    return {
      hotlist: [],
      hotlist1: [],
    };
  },
  mounted() {
    axios
      .get(
        "/api/mmdb/movie/v3/list/hot.json?ct=%E6%B7%B1%E5%9C%B3&ci=30&channelId=4",
        { ct: "深圳", ci: 30, channelId: 4 }
      )
      .then((res) => {
        console.log(res);
        this.hotlist = res.data.data.hot;
        this.hotlist1 = this.hotlist.concat([]);
        this.hotlist1.sort((a, b) => {
          return b.sc - a.sc;
        });
      });
  },
};
</script>

<style lang="less">
ul,
li {
  list-style: none;
}

.hot {
  width: 95%;
  margin: auto;
  /* border: 1px solid red; */
  overflow-x: scroll;
  .title {
    font-size: 14px;
    color: #333;
    margin: 0 0 12px;
  }
  ul {
    display: flex;
    width: 1100px;
    li {
      margin-right: 10px;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      width: 85px;
      height: 150px;
      font-weight: 600;
      font-size: 13px;
      /* border: 1px solid green; */
      img {
        width: 85px;
        height: 115px;
      }
      .pinfen {
        color: #d69500;
        font-size: 11px;
        font-weight: 600;
      }
    }
  }
}

.hot::-webkit-scrollbar {
  display: none;
}

.list ul li {
  display: flex;
  justify-content: space-around;
}

.list ul li .item-img {
  width: 30%;
}

.list ul li .item-img img {
  width: 100%;
}

.list ul li .item-text {
  width: 65%;
  display: flex;
  justify-content: space-around;
  color: #666;
}

.list ul li .item-text .item-tt {
  margin-top: 50px;
  width: 70%;
}

.list ul li .item-text .item-btn {
  width: 30%;
  margin: auto;
  margin-left: 20px;
}
</style> -->
<template>
  <div>
    <!-- 好评电影 -->
    <movie-praise :praiselist="praiselist"></movie-praise>
    <div class="line"></div>
    <!-- 热映模块 -->
    <movie-hot :hotlist="hotlist"></movie-hot>
  </div>
</template>

<script>
//引入热映组件
import MovieHot from "./MovieHot.vue";
import MoviePraise from "./MoviePraise.vue";
//引入 axios
import axios from "axios";

export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Hot",
  //注册
  components: {
    MovieHot,
    MoviePraise,
  },
  data() {
    return {
      hotlist: [],
      praiselist: [], //好评电影
    };
  },
  mounted() {
    axios
      .get(
        "/api/mmdb/movie/v3/list/hot.json?ct=%E6%B7%B1%E5%9C%B3&ci=30&channelId=4",
        { ct: "深圳", ci: 30, channelId: 4 }
      )
      .then((res) => {
        console.log(res);
        this.hotlist = res.data.data.hot;

        this.praiselist = [...this.hotlist];
        //排序
        this.praiselist.sort((a, b) => {
          return b.sc - a.sc;
        });
        console.log(this.praiselist);
      });
    
  },
};
</script>
<style lang="less" scoped>
.line {
  width: 100%;
  height: 10px;
  background: #eee;
  margin-bottom: 10px;
}
</style>